//分页参数
let page = {
  total: 1,
  startIndex: 0,
  stepNumber: 20,
  currentPage: 1
};

// 和网络交互相关的参数
let params = {
  type: '',
  email:'',
  selected:[],
  templateId:''
};



let status={
  sendEmailModal:{
    isShow: false,
    isLoading: false,
    title:'发送邮件',
  },
  ruleValidate: {
    templateId: [
      { required: true, message: '模板code不能为空', trigger: 'change' }
    ]
  }
}



// 页面的数据源
let data = {
  contactUserList: []
};

const tableRowActionEdit = function (self) {
  return {
    title: '操作',
    key: 'action',
    width: 120,
    align:'center',
    render: (h, params) => {
      return (
        <div>
          < i-button type="error" size="small"  style="margin-right:10px" onClick={() => {self.editContact(params.index)}}>修改用户</i-button>
        </div>
      );

    }
  }
};

let table = function (self) {
  return [
    {
      type: 'selection',
      width: 60,
      fixed: 'left',
      align: 'center',
    },
    {
      title: '序号',
      type: 'index',
      width: 80,
      align: 'center',
    },
    {
      title: '邮箱',
      align: 'center',
      key: 'email',
      width: 280,
    },
    {
      title: '姓名',
      align: 'center',
      key: 'fullName',
      minWidth: 80,
    },
    {
    title: '状态',
      key: 'state',
      width: 80,
      align:'center',
      render: (h, params) => {
      let type = params.row.state;
      let typeName = "";
      if (type===0){
        typeName = "禁用";
      }
      if (type===1){
        typeName = "正常";
      }
      return h('div',typeName);
    }
  },
    {
      title: '推送次数',
      align: 'center',
      key: 'pushTotal',
      width: 100,
      render: (h, params) => {
        return h('div',params.row.emailReocords.length);
      }
    },
    {
      title: '推送时间',
      key: 'pushtime',
      align: 'center',
      render: (h, params) => {
        if(params.row.emailReocords.length>0){
          return h('div',self.$tiyBJTime(params.row.emailReocords[0].createtime));
        }else{
          return h('div',"");
        }

      }
    },
    {
      title: '已注册',
      align: 'center',
      width: 80,
      key: 'userId',
      render: (h, params) => {
        let userId = params.row.userId;
        let registerd = "否";
        if (userId!=""){
          registerd = "是";
        }
        return h('div',registerd);
      }
    },
    {
      title: '创建时间',
      align: 'center',
      width: 180,
      key: 'createTime',
      render: (h, params) => {
        return h("span", self.$tiyBJTime(params.row.createtime));
      }
    },
    tableRowActionEdit(self)
  ];
}

export  default  {
  tPage: page,
  tParam: params,
  tData: data,
  tStatus: status,
  tTable:table,
};
